package com.newstart.timetask.project.utils.timeTask;

import org.springframework.util.StreamUtils;

import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.TimerTask;

/**
 * Created by Administrator on 2017/9/29.
 */
public class RankTask extends TimerTask {
    @Override
    public void run() {
        System.out.println("...............任务执行了.............");

        try {
            // 创建一个URL对象
            URL targetUrl = new URL("http://127.0.0.1:8082/timetask/api/v1/siteRentback/getParkingSiteRentbackNotify");
            // 从URL对象中获得一个连接对象
            HttpURLConnection conn = (HttpURLConnection) targetUrl.openConnection();
            // 设置请求方式 注意这里的POST或者GET必须大写
            conn.setRequestMethod("POST");
            // 设置POST请求是有请求体的
            conn.setDoOutput(true);
            // 读入响应
            String s = StreamUtils.copyToString(conn.getInputStream(), Charset.forName("UTF-8"));

        } catch (Exception e) {

        }
    }
}
